package com.flot.yazb.home.setting;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.EditText;

import com.flot.yazb.R;
import com.flot.yazb.base.BActivity;
import com.flot.yazb.base.BApplication;
import com.flot.yazb.model.user.UserModel;
import com.flot.yazb.widget.utils.SharedPreferencesUtils;

import java.util.HashMap;
import java.util.Map;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;


public class NeiXinDuBaiActivity extends BActivity {
    @BindView(R.id.etview)
    EditText etview;
    private UserModel model = BApplication.getInstance().getUserModel();

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_dubai);
        ButterKnife.bind(this);
        getDubai();
    }

    /**
     * 获取内心独白数据
     */
    private void getDubai() {
//        showProgress();
        String s=SharedPreferencesUtils.getString(activity,"db","");
        etview.setText(s);
//        DubaiModel.getDubai(model.id, new BModel.Transit<DubaiModel>(this) {
//            @Override
//            public void onBorn(DubaiModel serializable, String code, String message) {
//                dismissProgress();
//                if (code.equals(CodeStub.B_OK)) {
//                    etview.setText(serializable.beizhu);
//                } else {
//                    ToastUtil.showToast(activity, message);
//                }
//            }
//        });
    }


    /**
     * 设置备注
     */
    private void setBeizhu() {
        showProgress();
        Map map = new HashMap();
        map.put("id", model.id);
        map.put("beizhu", etview.getText().toString());
        SharedPreferencesUtils.saveString(activity,"db",etview.getText().toString());
        finish();
//        DubaiModel.setDubai(map, new BModel.Transit<DubaiModel>(this) {
//            @Override
//            public void onBorn(DubaiModel serializable, String code, String message) {
//                dismissProgress();
//                if (code.equals(CodeStub.B_OK)) {
//                    finish();
//                } else {
//                    ToastUtil.showToast(activity, message);
//                }
//            }
//        });
    }

    @OnClick({R.id.iv_back, R.id.ok})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.iv_back:
                finish();
                break;
            case R.id.ok:
                setBeizhu();
                break;
        }
    }
}
